//************************************************************************
/// <copyrigth>2024-2025 Corporation.All Rights Reserved</copyrigth>
/// <author>tangyingzhong</author>
/// <contact>tangyz114987@outlook.com</contact>
/// <version>v1.0.0</version>
/// <describe>
/// Cross-Platform date time
///</describe>
/// <date>2024/3/8</date>
///***********************************************************************
#ifndef DATETIME_H
#define DATETIME_H

#include "ModuleLoader/ModuleConfig.h"

namespace SystemTool
{
    class CLASS_ITEM DateTime
    {
    public:
        // Construct the date time
        DateTime();

        // Destruct the date time
        ~DateTime();
        
        // Copy construct 
        DateTime(const DateTime& other);

        // Assigment
        DateTime& operator=(const DateTime& other);

    public:
        // Get current time
        static DateTime Now();

        // Get time from string "2024-03-08 22:10:00"
        static DateTime FromString(std::string strStandardTime);

        // Timestamp to time
        static DateTime FromSTime_t(time_t iTime_S);

        // Timestamp to time
        static DateTime FromMsTime_t(time_t iTime_Ms);

        // Equal
        bool operator==(DateTime &other);

        // Get time's timestamp
        time_t ToSTime_t();

        // Get time's timestamp
        time_t ToMsTime_t();

        // Time to string
        std::string ToString();

        // Get time's year
        int GetYear();

        // Get time's month
        int GetMonth();

        // Get time's day
        int GetDay();

        // Get time's hour
        int GetHour();

        // Get time's minute
        int GetMinute();

        // Get time's second
        int GetSecond();

        // Get time's millisecond
        int GetMilliSecond();

        // Get time's microsecond 
        int GetMicroSecond();

    private:
        // Set the dt
        void SetDateTime();
        
        // Set time's year
        void SetYear_Inner();

        // Set time's month
        void SetMonth_Inner();

        // Set time's day
        void SetDay_Inner();

        // Set time's hour
        void SetHour_Inner();

        // Set time's minute
        void SetMinute_Inner();

        // Set time's second
        void SetSecond_Inner();

        // Set time's millisecond
        void SetMilliSecond_Inner();

        // Set time's microsecond
        void SetMicroSecond_Inner();

    private:
        // Poco date time
        void* m_pDateTime;

        // Year/Month/Day/Hour/Minute/Millisecond/Microsecond
        int m_iYear;
        int m_iMonth;
        int m_iDay;
        int m_iHour;
        int m_iMinute;
        int m_iSecond;
        int m_iMillisecond;
        int m_iMicrosecond;
    };
}

#endif // DATETIME_H